
{% set hostname = grains['id'] %}
{% set internal_salt = pillar['internal_salt'] %}
{% set internal_salt_ip = pillar['internal_salt_ip'] %}


{% if grains['os']  == 'CentOS' %}
  {% if grains['osrelease'].startswith('6') %}
    {% set osrelease = '6' %}
/etc/yum.repos.d/salt.el6.repo:
  file.managed:
    - source: salt://files/repos/salt.el6.repo
    - user: root
    - group: root
    - mode: 644

  {% elif grains['osrelease'].startswith('7') %}
    {% set osrelease = '7' %}
/etc/yum.repos.d/salt.el7.repo:
  file.managed:
    - source: salt://files/repos/salt-repo.el7.repo
    - user: root
    - group: root
    - mode: 644
/etc/yum.repos.d/Centos-7.repo:
  file.managed:
    - source: salt://files/repos/Centos-7.repo
    - user: root
    - group: root
    - mode: 644
/etc/yum.repos.d/epel-7.repo:
  file.managed:
    - source: salt://files/repos/epel-7.repo
    - user: root
    - group: root
    - mode: 644


selinux-config:
  file.managed:
    - name: /etc/selinux/config
    - source: salt://files/selinux/config
    - user: root
    - group: root
    - mode: 0644

  {% endif %}
{% endif %}


hostname_command_config:
  cmd.run:
    - name: |
        hostnamectl  set-hostname {{hostname}}
        echo "127.0.0.1 {{hostname}} " >>/etc/hosts
    - unless:  grep {{hostname}} /etc/hosts


salt_command_config:
  cmd.run:
    - name: echo "{{internal_salt_ip}} {{internal_salt}}" >>/etc/hosts
    - unless:  grep {{internal_salt}} /etc/hosts

